﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Text.RegularExpressions;
namespace G2
{
    class Program
    {
        public static void check(string id)
        {
            string parten = @"^\d{17}[0-9xX]$";
            if (id.Length!=18)
            {
                Console.WriteLine("格式错误");return;
            }
            string birth = id.Substring(6, 8).Insert(6, "-").Insert(4, "-");
           // Console.WriteLine(birth);
            DateTime date = new DateTime();

            int[] weight = { 7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2 };     // 加权数组
            string[] yanzhneg = { "1", "0", "X", "9", "8", "7", "6", "5", "4", "3", "2" };   // 校验数组
            int sum = 0;
            

            if (Regex.IsMatch(id, parten))
            {

                
                if (DateTime.TryParse(birth,out date))
                {
                    for (int i = 0; i < 17; i++)
                    {
                        sum += weight[i] * int.Parse(id[i].ToString());
                    }
                    int result = sum % 11;
                    if (yanzhneg[result] == id[17].ToString().ToUpper())
                    {
                        Console.WriteLine("正确");
                    }
                    else { Console.WriteLine("18位错误"); }
                }
                else { Console.WriteLine("出生日期错误"); }
            }
            else { Console.WriteLine("格式错误"); }
        }
        static void Main(string[] args)
        {
            while (true)
            {
                string id = Console.ReadLine();
                Program.check(id);
                //Console.ReadLine();
            }
        }
    }
}
